import java.util.HashMap;
import java.util.LinkedList;

public class L640 {

    public String solveEquation(String equation) {
        String[] arr1 = equation.split("=");
        int left =0;
        int right =0;

        String[] leftSplit = arr1[0].replaceAll("-", "+-").split("\\+");
        String[] rightSplit = arr1[1].replaceAll("-", "+-").split("\\+");

        for (String op : leftSplit) {
            if (op.equals("x")){
                left++;
            }else if (op.equals("-x")){
                left--;
            }else if (op.contains("x")){
                // 2x -2x
                left += Integer.parseInt(op.substring(0,op.length()-1));
            } else if (!op.isEmpty()) {
                right-=Integer.parseInt(op);
            }
        }

        // 等式右边的处理
        for (String op : rightSplit) {
            if (op.equals("x")) {
                left -= 1;
            } else if (op.equals("-x")) {
                left -= -1;
            } else if (op.contains("x")) {
                left -= Integer.parseInt(op.substring(0, op.length() - 1));
            } else if (!op.equals("")) {
                right += Integer.parseInt(op);
            }
        }

        if (left==0){
            if (right == 0) {
                return "Infinite solutions";
            }
            return "No solution";
        }
        return "x=" + right/left;

    }
}
